import request from '@/common/js/request.js'


const api = {
	getTodoListByUserid: "/di_todo/getTodoListByUserid",
	getTodo: "/ding/todo/view",
	getAttachByApplyid: "/di_todo/getAttachByApplyid",
	minioUpload: '/di_todo/upload',
	finishTodo: '/di_todo/finishRespond',
	getFileListByApplyId: "/di_todo/getFileListByApplyId"
}

/**
 * 根据接收人id获取待办任务
 * @param {Object} body
 */
export function getTodoListByUserid(body) {
	return request({
		url: api.getTodoListByUserid,
		method: "post",
		data: body
	})
}

/**
 * 获取待办详情
 * @param {Object} params
 */
export function getTodo(params) {
	return request({
		url: api.getTodo,
		method: "post",
		params: params
	})
}

/**
 * 根据applyid及类型查询附件信息
 * @param {Object} params
 */
export function getAttachByApplyid(params) {
	return request({
		url: api.getAttachByApplyid,
		method: "post",
		params: params
	})
}

/**
 * 办结待办
 * @param {Object} params
 * @param {Object} fileList
 */
export function finishTodo(params, fileList) {
	var body = new FormData()
	if (fileList != undefined && fileList.length > 0) {
		fileList.forEach(item => {
			body.append('files', item)
		})
		return request({
			url: api.finishTodo,
			headers: {
				'Conten-Type': 'mulitpart/form-data'
			},
			method: 'post',
			params: params,
			data: body
		})
	}
}

/**
 * 根据applyid mattype 查询被申请人答复书附件
 * @param {Object} params
 */
export function getFileListByApplyId(params) {
	return request({
		url: api.getFileListByApplyId,
		method: "post",
		params: params
	})
}